/************************************************************************
 * MechSys - Open Library for Mechanical Systems                        *
 * Copyright (C) 2013 Maziar Gholami Korzani and Sergio Galindo Torres  *
 *                                                                      *
 * This program is free software: you can redistribute it and/or modify *
 * it under the terms of the GNU General Public License as published by *
 * the Free Software Foundation, either version 3 of the License, or    *
 * any later version.                                                   *
 *                                                                      *
 * This program is distributed in the hope that it will be useful,      *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         *
 * GNU General Public License for more details.                         *
 *                                                                      *
 * You should have received a copy of the GNU General Public License    *
 * along with this program. If not, see <http://www.gnu.org/licenses/>  *
 ************************************************************************/

#ifndef MECHSYS_SPH_PARTICLE_H
#define MECHSYS_SPH_PARTICLE_H

// Std lib
#include <iostream>
#include <cstring>
#include <cmath>
#include <omp.h>

// MechSys
#include <mechsys/linalg/matvec.h>

namespace SPH {

class Particle
{
public:

    // Constructor
    Particle(int Tag, Vec3_t const & x0, Vec3_t const & v0, double Mass0, double Density0, double h0, bool Fixed);


    // Data
    bool   	IsFree;			///< Check the particle if it is free to move or not
    Vec3_t  x;				///< Position of the particle n
    Vec3_t  v;				///< Velocity of the particle n+1,

    double 	Pressure;		///< Pressure at the position of the particle
    double	Density;		///< Density at the position of the particle
    double 	Mass;			///< Mass of the particle

    double 	h;				///< Smoothing length of the particle

    int    	ID;				///< an Integer value to identify type of the particles
    int    	LL;				///< Linked-List variable to show next particle in list of a cell
    int		No;				///< No of particles for averaging

    double	ZWab;			///< Summation of the mb/db*Wab
    omp_lock_t my_lock;		///< Open MP lock
};

inline Particle::Particle(int Tag, Vec3_t const & x0, Vec3_t const & v0, double Mass0, double Density0, double h0,bool Fixed)
{
    x			= x0;
    v			= v0;
    Density		= Density0;
    Mass		= Mass0;
    IsFree		= !Fixed;
    h			= h0;
    Pressure	= 0.0;
    ID			= Tag;
    LL			= -1;
    No			= 1;
    ZWab		= 0.0;
    omp_init_lock(&my_lock);
}

}; // namespace SPH

#endif // MECHSYS_SPH_PARTICLE_H
